﻿package frEngine.shader
{
    import frEngine.shader.filters.fragmentFilters.*;
    import frEngine.shader.filters.vertexFilters.*;

    public class UseOriTexShaderbase extends ShaderBase
    {
        public var useOriginTexture:Boolean;
        private static var pool:Array = [];

        public function UseOriTexShaderbase(param1:String, param2:Boolean, param3:VertexFilter = null, param4:FragmentFilter = null)
        {
            super(param1, param3, param4);
            this.useOriginTexture = param2;
            return;
        }// end function

        override public function clear() : void
        {
            if (this.useOriginTexture)
            {
                this.materialParams.fragmentFilter = null;
            }
            return;
        }// end function

        public static function getInstanceFromPool(param1:String, param2:Boolean, param3:VertexFilter = null, param4:FragmentFilter = null) : UseOriTexShaderbase
        {
            var _loc_5:UseOriTexShaderbase = null;
            if (pool.length == 0)
            {
                return new UseOriTexShaderbase(param1, param2, param3, param4);
            }
            _loc_5 = pool.shift();
            _loc_5.materialParams.vertexFilter = param3;
            _loc_5.materialParams.fragmentFilter = param4;
            _loc_5.useOriginTexture = param2;
            return _loc_5;
        }// end function

        public static function disposeInstance(param1:UseOriTexShaderbase, param2:Boolean) : void
        {
            if (!param1)
            {
                return;
            }
            if (pool.indexOf(param1) == -1)
            {
                pool.push(param1);
            }
            if (param1.useOriginTexture)
            {
                param1.materialParams.fragmentFilter = null;
            }
            if (param2)
            {
                param1.dispose();
            }
            return;
        }// end function

    }
}
